Debian 10 - SVN server Kategoria: Linux | Tagi: subversion, svn, viewvc | Autor: Bartłomiej Gałęzia

1. Install SVN packages

sudo apt-get install apache2 subversion libapache2-mod-svn libsvn-dev
sudo a2enmod dav
sudo a2enmod dav_svn

2. Modify config

vim /etc/apache2/mods-enabled/dav_svn.conf
#jeśli wszystkie repo są w jednym miejscu
<Location /svn>
DAV svn
SVNParentPath /home/svn
AuthType Basic
AuthName "Subversion Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>
#jeśli repo są w różnych katalogach
<Location /repotest>
DAV svn
SVNParentPath /home/projekty/repotest
AuthType Basic
AuthName "Testowe Repository"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>
<Location /repotest2>
DAV svn
SVNParentPath /home/projekty/repotest2
AuthType Basic
AuthName "Testowe Repository 2"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>
service apache2 restart

3. Create repo

mkdir -p /home/svn/
svnadmin create /home/svn/testrepo
chown -R www-data:www-data /home/svn
chmod -R 775 /home/svn

4. Create users

htpasswd -cm /etc/apache2/dav_svn.passwd admin #cm - tworzy plik passwd lub go nadpisuje
htpasswd -m /etc/apache2/dav_svn.passwd user1 #m dodaje do istniejącego pliku

5. Access repo via browser

http://10.20.30.40/svn/testrepo/

or command line

svn checkout http://10.20.30.40/svn/testrepo/ --username user1

6. Debug

"svn: E195019: Redirect cycle detected for URL 'http://10.20.30.40/svn/testrepo'"
vim /etc/apache2/mods-enabled/dav_svn.conf
...
#Alias /svn /home/svn
...
service apache2 restart

Źródło:

https://www.linuxcloudvps.com/blog/how-to-install-svn-server-on-debian-9/

https://groups.google.com/g/subversion_users/c/mvjBxVY5d7k?pli=1

7. ViewVC

aptitude install viewvc
sudo a2enmod cgi
vim /etc/apache2/mods-enabled/dav_svn.conf
...
ScriptAlias /viewvc /usr/lib/cgi-bin/viewvc.cgi
...
<Location /svn>
...
vim /etc/viewvc/viewvc.conf
#jeśli wszystkie repo są w jednym katalogu
root_parents = /home/svn : svn
#jeśli każde repo na osobną ścieżkę
vn_roots = Test repo :/home/projekty/testrepo,Test repo 2 :/home/projekty/testrepo2
#muszą być po przecinku ale w tej samej linii
service apache2 restart
http://10.20.30.40/viewvc/

8. ViewVC - Access control

vim /etc/apache2/mods-enabled/dav_svn.conf
<Location /viewvc>
AuthType Basic
AuthName "ViewSVN"
AuthUserFile /etc/apache2/dav_svn.passwd
Require valid-user
</Location>

https://nd.psychstat.org/blog/install_and_use_subversion_svn_and_viewvc_on_ubuntu

9. Autostart svnserve
#bez tego nie działa połączenie po protokole svn://

vim /etc/systemd/system/svnserve.service
[Unit]
Description=SVN server
After=network.target

[Service]
User=roo
Group=root
Type=forking
ExecStart=/usr/bin/svnserve -d --threads

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable svnserve
systemctl start svnserve

https://serverfault.com/questions/1040489/svn-server-start-at-boot
https://superuser.com/questions/1156676/what-causes-systemd-failed-at-step-user-spawning-usr-sbin-opendkim-no-such-p

10. LDAP authorization

a2enmod authnz_ldap
vim /etc/apache2/mods-enabled/dav_svn.conf
<Location /testrepo> 
DAV svn 
SVNParentPath /home/projekty/testrepo 
AuthType Basic 
AuthName "Testowe Repository"
AuthBasicProvider ldap 
AuthLDAPBindDN "CN=[adminuser],CN=Users,DC=etc,DC=pzl" 
AuthLDAPBindPassword "[adminpass]" 
AuthLDAPURL "ldap://10.50.10.69:389/OU=SBSUsers,OU=Users,DC=etc,DC=pzl?sAMAccountName?sub?(objectClass=*)" NONE 
Require valid-user
</Location

11. Authorization by passwd file

vim /repofolder/conf/svnserve.conf
[general]
anon-access = none
password-db = passwd
vim /repofolder/conf/passwd
[users]
username = password
service apache2 restart
service svnserve restart

Dodaj komentarz

Brak komentarzy, bądź pierwszy i dodaj swój komentarz